package liangtWorkSpace.threadDemo.station;

/**
 * @ClassName Station
 * @Description : 测试多线程
 * @Author : LiangT
 * @Date : 2020/7/4 16:09
 */
public class Station extends Thread{

    public Station(String name){
        super(name);
    }

    static int tick=20;

    static Object ob = "aa";

    @Override
    public void run(){
        while (tick > 0){
            synchronized(ob){
                if (tick> 0){
                    System.out.println(getName()+"卖出去了"+tick+"张票");
                    tick--;
                }else {
                    System.out.println("票卖完了");
                }
            }
            try {
                sleep(1000);
            }catch (Exception e){
                e.printStackTrace();
            }
        }

    }
}
